<html>
<head>
<title>KBEngine - KBEngine dbmgr</title>
<link href="../../style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td align=left style="background:#708090"> <font size=15 color=#ffffff> KBEngine </font></td></tr>
</table> <hr>
<h1>KBEngine module</h1>
This <a href="KBEngine.html">KBEngine</a> module provides Python scripts to 
control the dbmgr process to handle entity login queries and data access.


<h2><a href="#" onClick="obj=document.getElementById( 'functions' );vis = (obj.style.display == 'none') ? 'block' : 'none'; obj.style.display = vis; return false;" class="h2">Member functions</a></h2>
<table id="functions" cellpadding=0 cellspacing=3 style="margin-left: 20px;">

<tr><td>
<span class="function_list">def <a href="#addTimer" class="function_list" >addTimer</a>( initialOffset, repeatOffset=0, callbackObj=None ):</span>
</td></tr>

<tr><td>
<span class="function_list">def <a href="#delTimer" class="function_list" >delTimer</a>( id ):</span>
</td></tr>

</table>

<h2><a href="#" onClick="obj=document.getElementById( 'callbacks' );vis = (obj.style.display == 'none') ? 'block' : 'none'; obj.style.display = vis; return false;" class="h2">Callbacks</a></h2>
<table id="callbacks" cellpadding=0 cellspacing=3 style="margin-left: 20px;">

<tr><td>
<span class="function_list">def <a href="#onDBMgrReady" class="function_list" >onDBMgrReady</a>( ):</span>
</td></tr>

<tr><td>
<span class="function_list">def <a href="#onDBMgrShutDown" class="function_list" >onDBMgrShutDown</a>( ):</span>
</td></tr>

<tr><td>
<span class="function_list">def <a href="#onReadyForShutDown" class="function_list" >onReadyForShutDown</a>( ):</span>
</td></tr>

<tr><td>
<span class="function_list">def <a href="#onSelectAccountDBInterface" class="function_list" >onSelectAccountDBInterface</a>( accountName ):</span>
</td></tr>

</table>


<hr>
<h2>Member functions documentation</h2>

<a name="addTimer"></a><p class="function_definition">
<span class="function_definition">def addTimer( <i>initialOffset, repeatOffset=0, callbackObj=None</i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
Registers a timer. The timer triggers the callback function specified 
by callbackObj. The callback will be executed the first time after 
"initialOffset" seconds, and then executed once every "repeatOffset" 
seconds.
<br><br>
Example:

<pre><pre># Here is an example of using addTimer
        import <a href="../Modules/KBEngine.html">KBEngine</a>
&nbsp;
        # Add a timer, perform the first time after 5 seconds, and execute once every 1 second. The user parameter is 9
        KBEngine.addTimer( 5, 1, onTimer_Callbackfun )
&nbsp;
        # Add a timer and execute it after 1 second. The default user parameter is 0.
        KBEngine.addTimer( 1, onTimer_Callbackfun )
&nbsp;
    def onTimer_Callbackfun( id ):
        print "onTimer_Callbackfun called: id %i" % ( id )
        # If this is a repeated timer, it is no longer needed, call the following function to remove: 
        #     KBEngine.delTimer( id )</pre>
</pre>
</div>

<p>
<span class="function_parameter">parameters:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">

<tr valign=top><td><span class="function_parameter_name"><i>initialOffset</i></span></td><td><span class="function_parameter_description">
float, specifies the time interval in seconds for the timer to register 
the first callback.
</span></td></tr>

<tr valign=top><td><span class="function_parameter_name"><i>repeatOffset</i></span></td><td><span class="function_parameter_description">
float, specifies the time interval (in seconds) after each execution of 
the first callback execution. You must remove the timer with the function 
<a href="#delTimer">delTimer</a>, otherwise it will continue to repeat. 
Values less than or equal to 0 will be ignored.
</span></td></tr>

<tr valign=top><td><span class="function_parameter_name"><i>callbackObj</i></span></td><td><span class="function_parameter_description">
function, the specified callback function object.
</span></td></tr>

</table>
</p>

<p>
<span class="function_return">returns:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">
<tr><td>integer, this function returns the internal id of the timer. 
This id can be used to remove the timer using <a href="#delTimer">delTimer</a>.
</td></tr>
</table>
</p>



<a name="delTimer"></a><p class="function_definition">
<span class="function_definition">def delTimer( <i>id</i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
The delTimer function is used to remove a registered timer. The removed 
timer is no longer executed. Single-shot timers are automatically removed 
after the callback is executed, and it is not necessary to use delTimer 
to remove it. If the delTimer function receives an invalid id (for 
example, it was removed), it will generate an error.

<br><br>
A use case is in the KBEngine.<a href="#addTimer">addTimer</a> example.
</div>

<p>
<span class="function_parameter">parameters:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">

<tr valign=top><td><span class="function_parameter_name"><i>id</i></span></td><td><span class="function_parameter_description">
integer, specifies the timer id to remove.
</span></td></tr>

</table>
</p>




<hr>
<h2>Callback functions documentation</h2>

<a name="onDBMgrReady"></a><p class="function_definition">
<span class="function_definition">def onDBMgrReady( <i></i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
This function is called back when the current process is ready.
<br>Note: This callback interface must be implemented in the portal module ( kbengine_defaults.xml ->entryScriptFile).
</div>



<a name="onDBMgrShutDown"></a><p class="function_definition">
<span class="function_definition">def onDBMgrShutDown( <i></i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
This function is called when the process shuts down.
<br>Note: This callback interface must be implemented in the portal module ( kbengine_defaults.xml ->entryScriptFile).
</div>



<a name="onReadyForShutDown"></a><p class="function_definition">
<span class="function_definition">def onReadyForShutDown( <i></i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
If this function is implemented in a script, the callback function is called when the process is ready to exit.<br><br>

You can use this callback to control when the process exits.<br>
<br>Note: This callback interface must be implemented in the portal module ( kbengine_defaults.xml ->entryScriptFile).
</div>

<p>
<span class="function_return">returns:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">
<tr><td>
bool, if it returns True, it allows the process to exit. Returning other 
values will cause the process to ask again after a period of time.
</td></tr>
</table>
</p>



<a name="onSelectAccountDBInterface"></a><p class="function_definition">
<span class="function_definition">def onSelectAccountDBInterface( <i>accountName</i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
When implemented in a script, this callback returns the database interface 
corresponding to an account. After the interface is selected, the dbmgr 
operations related to this account are completed by the corresponding 
database interface.
<br><br>
Database interfaces are defined in <a href=../../keywords.html#kbengine_defaults.xml>kbengine_defaults.xml</a>->dbmgr->databaseInterfaces.<br>
Use this function to determine which database the account should be stored 
in based on accountName.<br>
<br>Note: This callback interface must be implemented in the portal module ( kbengine_defaults.xml ->entryScriptFile).<br>
</div>

<p>
<span class="function_parameter">parameters:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">

<tr valign=top><td><span class="function_parameter_name"><i>accountName</i></span></td><td><span class="function_parameter_description">
string, the name of the account.
</span></td></tr>

</table>
</p>

<p>
<span class="function_return">returns:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">
<tr><td>
string, the database interface name (database interfaces are defined in <a href=../../keywords.html#kbengine_defaults.xml>kbengine_defaults.xml</a>->dbmgr->databaseInterfaces).
</td></tr>
</table>
</p>




<hr>
<p class="copyrightFooter">Copyright KBEngine</p>
</body>
</html>
